<template>
    <div>
        <header>
            <p>爆爆团</p>
            <p>限时爆款 超级低价</p>
        </header>
        <div class="mid">
            <span @click="qianggouing" :class="qg ? 'active' : ''">正在抢购</span>
            <span @click="qianggoupre" :class="sx ? 'active' : ''">上新抢购</span>
        </div>
        <main>
            <div class="list" v-for="(item, index) in list || tanklist" :key=index>
                <div class="listleft">
                    <img :src="item.picture" alt="">
                </div>
                <div class="listright" v-if="tanklist.length">
                    <p>{{ item.name }}</p>
                    <p>{{ item.month_saled_content }}</p>
                    <div class="down">
                        <span>￥{{ item.min_price }}</span>
                        <div @click="qiang(item)">{{ item.status == 1 ? "马上抢" : item.status == 0 ? "马上抢" : "已抢购" }}
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

</template>

<script setup>
import { tuan_list } from '../../api/index'
import { onMounted, ref } from 'vue';
var qiangshop = ref()
var qg=ref(true)
var sx=ref(false)
var tanklist = ref([])
var qiang = (item) => {
    if (item.status == 1 || item.status == 0) {
        item.status = 2
    } else {
        item.status = 1
    }
}
var qianggouing = () => {
    this.sx = false;
    this.qg = !this.qg;
    this.list = this.tanklist
}
var qianggoupre=()=>{
            this.qg=false;
            this.sx=!this.sx;
            this.list=this.qiangshop
        }
onMounted((res) => {
    //正在抢购
    tuan_list({ status: 1 }).then((res) => {
        qiangshop.value = res.data.list
    }),
        //准备抢购
        tuan_list({ status: 0 }).then((res) => {
            tanklist.value = res.data.list
        })
})

</script>

<style scoped>
header {
    height: 150px;
    width: 100%;
    background-color: rgba(244, 58, 58, 0.81);
    color: rgb(239, 228, 228);
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
}

header p:nth-child(1) {
    font-size: 18px;
    font-style: italic;
    margin-top: 20px;
}

header p:nth-child(2) {
    font-size: 24px;
    margin-top: 65px;
    color: white;
}

main {
    width: 100%;
    height: 500px;
    overflow: auto;
}

.mid {
    height: 40px;
    width: 100%;
    margin-right: 20px;
    background-color: rgba(244, 58, 58, 0.81);
}

.mid span {
    margin-right: 20px;
    color: white;
    margin: 15px;
}

.mid span.active {
    color: red;
}

.list {
    height: 120px;
    width: 100%;
    box-shadow: 0px 0px 2px;
    display: flex;
    box-sizing: border-box;
}

.list .listleft {
    width: 35%;
    height: 100%;
}

.list .listleft img {
    width: 90%;
    margin: 10px;
    padding-top: 10px;
}

.list .listright {
    width: 65%;
    height: 100%;
    margin-left: 10px;
    box-sizing: border-box;
}

.list .listright p:nth-child(1) {
    font-size: 12px;
    color: rgb(144, 145, 146);
    margin-top: 20px;
}

.list .listright p:nth-child(2) {
    font-size: 14px;
    font-weight: 700;
    margin-top: 10px;
}

.down {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.down span {
    color: red;
}

.down div {
    height: 20px;
    width: 60px;
    border-radius: 12px;
    text-align: center;
    color: white;
    line-height: 20px;
    font-size: 12px;
    background-color: red;
    margin-right: 20px;

}
</style>